package practice08;

public class Teacher extends Person{
    //再写一个Teacher类继承Person类，除了id，name，age属性，也有Klass属性。也有一个introduce方法，
    //introduce方法返回一个字符串形如：
    //>My name is Tom. I am 21 years old. I am a Teacher. I teach Class 2.
    //如果Klass为空，就会返回：
    //>My name is Tom. I am 21 years old. I am a Teacher. I teach No Class.
//    Klass klass;
//    public Teacher(int id, String name, int age, Klass klass) {
//        super(id,name,age);
//        this.klass=klass;
//    }
//
//    public Teacher(int id, String name, int age) {
//        super(id, name, age);
//    }
//
//    public boolean getKlass() {
//        return false;
//    }
//     public String introduce() {
//        String words = super.introduce() + " I am a Teacher.";
//        words += this.klass != null ? String.format(" I teach Class %d.", this.klass.getNumber())
//                : " I teach No Class.";
//        return words;}
//
//    public boolean introduceWith(Student jerry) {
//        return false;
//    }
    private Klass klass;

    public Klass getKlass() {
        return klass;
    }

    public void setKlass(Klass klass) {
        this.klass = klass;
    }

    public Teacher(Integer id,String name, Integer age, Klass klass) {
        super(id,name, age);
        this.klass = klass;
    }

    public Teacher(Integer id, String name, Integer age) {
        super(id, name, age);
    }

    public String introduceWith(Student student){
        String words = String.format("My name is %s. I am %d years old. I am a Teacher.", this.getName(), this.getAge());
        words += student.getKlass().equals(this.klass)? String.format(" I teach %s.",student.getName()) : String.format(" I don't teach %s.",student.getName());
        return words;
    }

    @Override
    public String introduce() {
        String words = super.introduce() + " I am a Teacher.";
        words += this.klass != null ? String.format(" I teach Class %d.", this.klass.getNumber())
                : " I teach No Class.";
        return words;
    }
}
